<?php echo $header;echo $sidebar ?>		
	
	<link rel="stylesheet" href="<?php echo base_url(); ?>assets/admin/css/new_font-awesome.css"/>
	<link href="<?php echo $this->config->base_url(); ?>assets/admin/css/jquery-ui.css" rel="stylesheet">
	<link href="<?php echo $this->config->base_url(); ?>assets/admin/css/chosen.css" rel="stylesheet">
	<link href="<?php echo $this->config->base_url(); ?>assets/admin/css/chosen-bootstrap.css" rel="stylesheet">
	<script type="text/javascript" src="<?php echo $this->config->base_url(); ?>assets/admin/js/chosen.jquery.js"></script>
	<script type="text/javascript" src="<?php echo $this->config->base_url(); ?>assets/admin/js/jquery-ui.js"></script>
	<script src="<?php echo $this->config->base_url(); ?>assets/admin/media/js/jquery.dataTables.columnFilter.js" type="text/javascript"></script>
	<style type="text/css">
	.text_filter {
		width: 100% !important;
		border: 0 !important;
		box-shadow: none !important;
		border-radius: 0 !important;
		padding:0 !important;
		margin:0 !important;
		font-size: 1em !important;
	}
	.select_filter {
		width: 100% !important;
		padding:0 !important;
		height: auto !important;
		margin:0 !important;
	}
	.btn-group, .btn-group-vertical {display: inline-block;position: relative;vertical-align: middle;}
	* {border-radius: 0 0 0 0 !important;box-shadow: none !important;font-family: "Open Sans",Arial,Helvetica,sans-serif;font-weight: 400;text-shadow: none !important;}
	.btn-group > .btn:first-child {margin-left: 0;}
	.btn-group a.btn {margin: 0 !important;}
	.btn.btn-primary {background: none repeat scroll 0 0 #1171A3 !important;}
	.btn-xs {padding: 1px 5px;}
	.btn-sm, .btn-xs {border-radius: 3px 3px 3px 3px;font-size: 12px;line-height: 1.5;padding: 2px 5px;}
	
	.modal-header .close {margin-top: -2px;}
	.modal-content {box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);}
	.modal-content {
		background-clip: padding-box;
	    background-color: #FFFFFF;
	    border: 1px solid rgba(0, 0, 0, 0.2);
	    border-radius: 6px 6px 6px 6px;
	    box-shadow: 0 3px 9px rgba(0, 0, 0, 0.5);
	    outline: 0 none;
	    position: relative;
	}	
	button.close {background: none repeat scroll 0 0 transparent;border: 0 none;cursor: pointer;padding: 0;}
	.col-md-6{float:left;width:47%;}
	#dataTables_filter{float:right;}
	
	.col-xs-1, .col-xs-2, .col-xs-3, .col-xs-4, .col-xs-5, .col-xs-6, .col-xs-7, .col-xs-8, .col-xs-9, .col-xs-10, .col-xs-11, .col-xs-12, .col-sm-1, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-sm-10, .col-sm-11, .col-sm-12, .col-md-1, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9, .col-md-10, .col-md-11, .col-md-12, .col-lg-1, .col-lg-2, .col-lg-3, .col-lg-4, .col-lg-5, .col-lg-6, .col-lg-7, .col-lg-8, .col-lg-9, .col-lg-10, .col-lg-11, .col-lg-12 {
    	min-height: 1px;
    	padding-left: 15px;
    	padding-right: 15px;
    	position: relative;
	}
	</style>
	
	<script type="text/javascript" charset="utf-8">
			$(document).ready( function () {

				function format_date(oObj) {
					var aDate = oObj.split('-');
					<?php if(JS_DATE == 'dd-mm-yy') { ?>
					return aDate[2] + "-" + aDate[1] + "-" + aDate[0];
					<?php } elseif(JS_DATE == 'dd/mm/yy') { ?>
					return aDate[2] + "/" + aDate[1] + "/" + aDate[0];
					<?php } elseif(JS_DATE == 'dd.mm.yy') { ?>
					return aDate[2] + "." + aDate[1] + "." + aDate[0];
					<?php } elseif(JS_DATE == 'mm/dd/yy') { ?>
					return aDate[1] + "/" + aDate[2] + "/" + aDate[0];
					<?php } elseif(JS_DATE == 'mm-dd-yy') { ?>
					return aDate[1] + "-" + aDate[2] + "-" + aDate[0];
					<?php } elseif(JS_DATE == 'mm.dd.yy') { ?>
					return aDate[1] + "." + aDate[2] + "." + aDate[0];
					<?php } else { ?>
					return sValue;
					<?php } ?>
				}
				
				
				
				$('#fileData').on('click', '.email_inv', function() {
					var vid = $(this).attr('id');
					var cid = $(this).attr('data-customer');
					$.getJSON( "<?php echo base_url(); ?>index.php/admin/saleGetCE", { id: cid, <?php echo $this->security->get_csrf_token_name(); ?>: '<?php echo $this->security->get_csrf_hash() ?>' }).done(function( json ) {
						$('#customer_email').val(json.ce);
					});
					
					$('#emailModalLabel').text('<?php echo $this->lang->line("customer_email")." ".$this->lang->line("quote")." ".$this->lang->line("sale_no"); ?> '+vid);
					$('#subject').val('<?php echo $this->lang->line("quote")." from ".SITE_NAME; ?>');
					$('#qu_id').val(vid);
					$('#emailModal').modal();
					return false;
				});

				$('#emailModal').on('click', '#email_now', function() {
					$(this).text('Sending...');
					var vid = $('#qu_id').val();
					var to = $('#customer_email').val();
					var subject = $('#subject').val();
					var note = $('#message').val();
		
					if(to != '') {
						$.ajax({
							  type: "post",
							  url: "<?php echo base_url(); ?>index.php/admin/saleSendQuote",
							  data: { id: vid, to: to, subject: subject, note: note, <?php echo $this->security->get_csrf_token_name(); ?>: '<?php echo $this->security->get_csrf_hash() ?>' },
							  success: function(data) {
								alert(data);
							  },
							  error: function(){
		       					alert('<?php echo $this->lang->line('sale_ajax_error'); ?>');
		    				  }
						});
					} else { alert('<?php echo $this->lang->line('sale_to'); ?>'); }
					$('#emailModal').modal('hide');
					$(this).text('<?php echo $this->lang->line('sale_send_email'); ?>');
					return false;
					
				});
				
			});
	</script>
		
	
	<div class="span10 content">

		<?php echo $hugemenu ?>
		
		<h1><?php echo lang('quotations');?></h1>
		
		<?php if($success_message) { echo "<div class=\"alert alert-success\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\">&times;</button>" . $success_message . "</div><br />"; } ?>
		<?php if($message) { echo "<div class=\"alert alert-danger\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\">&times;</button>" . $message . "</div><br />"; } ?>
		

		<div>
			<table id="fileData" cellpadding=0 cellspacing=10 class="table table-bordered table-hover table-striped" style="margin-bottom: 5px;">
		      <thead>
		        <tr>
		          <th><?php echo $this->lang->line("sale_date"); ?></th>
		          <th><?php echo $this->lang->line("sales_property_id"); ?></th>
		          <th><?php echo $this->lang->line("sales_property_title"); ?></th>
		          <th><?php echo $this->lang->line("sale_created_by"); ?></th>
		          <th><?php echo $this->lang->line("sales_customer"); ?></th>
		          <th><?php echo $this->lang->line("sales_property_price"); ?></th>
		          <th><?php echo $this->lang->line("sales_taxes"); ?></th>
		          <th><?php echo $this->lang->line("sales_total"); ?></th>
		          <th><?php echo $this->lang->line("sales_down_payment"); ?></th>
		          <th><?php echo $this->lang->line("sales_monthly_payment"); ?></th>
		          <th><?php echo $this->lang->line("sales_months"); ?></th>
		          <th style="width:160px; text-align:center;"><?php echo $this->lang->line("sale_actions"); ?></th>
		        </tr>
		      </thead>
		      <tbody>
		       <?php foreach($quotes as $row){
		       	?>
		       	<tr>
		       		<td><?php echo $row->date;?></td>
		       		<td><?php echo $row->estate_id;?></td>
		       		<td><?php echo $row->title;?></td>
		       		<td><?php echo $row->user;?></td>
		       		<td><?php echo $row->customer_name;?></td>
		       		<td><?php echo $row->price;?></td>
		       		<td><?php echo $row->total_tax;?></td>
		       		<td><?php echo $row->total;?></td>
		       		<td><?php echo $row->down_payment;?></td>
		       		<td><?php echo $row->monthly_payment;?></td>
		       		<td><?php echo $row->months;?></td>
		       		<td>
		       			<center>
			    			<div class='btn-group' style='margin:0;'>
			    				<!-- <a class=\"tooltp add_payment btn btn-success btn-xs\" data-toggle=\"tooltip\" title='".$this->lang->line("sale_add_payment")."' href='#' id='$1' data-customer='$2'><i class=\"fa fa-briefcase\"></i></a> -->
			    				<a class="tooltp btn btn-success btn-xs" data-toggle="tooltip" title='<?php echo $this->lang->line("view_invoice");?>' href='#' onClick="MyWindow=window.open('saleViewInvoice?id=$1', 'MyWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=1000,height=600'); return false;"><i class="fa fa-file-text-o"></i></a>
			    				<a class="tooltp btn btn-primary btn-xs" data-toggle="tooltip" title='<?php echo $this->lang->line("download_pdf");?>' href='salePdf?id=$1'><i class="fa fa-download"></i></a>
								<!-- <a class=\"tooltp email_inv btn btn-success btn-xs\" data-toggle=\"tooltip\" title='".$this->lang->line("email_invoice")."' href='#' id='$1' data-customer='$2'><i class=\"fa fa-envelope\"></i></a> -->
								<a class="tooltp btn btn-warning btn-xs" data-toggle="tooltip" title='<?php echo $this->lang->line("edit_invoice");?>' href='saleEdit?id=$1'><i class="fa fa-edit"></i></a>
								<a class="tooltp btn btn-danger btn-xs" data-toggle="tooltip" title='<?php echo $this->lang->line("delete_invoice");?>' href='saleDelete?id=$1' onClick="return confirm('<?php $this->lang->line('alert_x_invoice'); ?>')"><i class="fa fa-trash-o"></i></a>
							</div>
						</center>
		       		</td>
		       	</tr>
		       	<?php
		       	} ?>
		      </tbody>
		    </table>
		    <br />
		    <p><a href="<?php echo site_url('admin/salesAddQuotation');?>" class="btn btn-primary"><?php echo $this->lang->line("add_quote"); ?></a></p>
		    
		    
		
	</div><!--/content-->
	<script src="<?php echo $this->config->base_url(); ?>assets/admin/js/jquery-ui-1.10.2.custom.min.js"></script> <!-- jQuery UI -->
	<script src="<?php echo $this->config->base_url(); ?>assets/admin/js/sparklines.js"></script>
	<script src="<?php echo $this->config->base_url(); ?>assets/admin/js/fullcalendar.min.js"></script> <!-- Full Google Calendar - Calendar -->
	<script src="<?php echo $this->config->base_url(); ?>assets/admin/js/bootstrap-datetimepicker.min.js"></script> <!-- Date picker -->
	<script src="<?php echo $this->config->base_url(); ?>assets/admin/js/DT_bootstrap.js"></script> <!-- jQuery UI -->
	<script src="<?php echo $this->config->base_url(); ?>assets/admin/js/jquery.prettyPhoto.js"></script> <!-- prettyPhoto -->
	 
	 <div class="control-group modal fade" id="payModal" tabindex="-1" role="dialog" aria-labelledby="payModalLabel" aria-hidden="true">
		<div class="modal-dialog">
		    <div class="modal-content">
		      <div class="modal-header">
		        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
		        <h4 class="modal-title" id="myModalLabel"><?php echo $this->lang->line('sale_add_payment'); ?></h4>
		      </div>
		      <div class="modal-body">
		        <div class="control-group">
		          <label class="control-label" for="amount"><?php echo $this->lang->line("sale_amount_paid"); ?></label>
		          <div class="controls"> <?php echo form_input('amount', '', 'class="input-block-level" id="amount"');?> </div>
		        </div>
		        <div class="control-group">
		          <label class="control-label" for="note"><?php echo $this->lang->line("note"); ?></label>
		          <div class="controls"> <?php echo form_textarea('note', '', 'class="input-block-level" id="note" style="height:100px;"');?> </div>
		        </div>
		        <input type="hidden" name="cid" value="" id="cid" />
		        <input type="hidden" name="vid" value="" id="vid" />
		      </div>
		      <div class="modal-footer">
		        <button class="btn" data-dismiss="modal" aria-hidden="true"><?php echo $this->lang->line('sale_close'); ?></button>
		        <button class="btn btn-primary" id="add-payment"><?php echo $this->lang->line('sale_add_payment'); ?></button>
		      </div>
		    </div>
		</div>
	</div>
			
	<div class="control-group modal fade" id="emailModal" tabindex="-1" role="dialog" aria-labelledby="emailModalLabel" aria-hidden="true">
  		<div class="modal-dialog">
			<div class="modal-content">
				    
			      <div class="modal-header">
			        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
			        <h4 class="modal-title" id="emailModalLabel"></h4>
			      </div>
				      
				  <div class="modal-body">
				  	<div class="form-group">
				  		<label for="from"><?php echo $this->lang->line("from"); ?></label>
				  		<div class="controls"> <strong><?php echo $from_name; echo " &lt;".$from_email."&gt;"; /*form_input($from_name, '', 'class="text"'); */ ?></strong></div>
					</div>
					<div class="form-group">
			  			<label for="customer_email"><?php echo $this->lang->line("to"); ?></label>
			  			<div class="controls"> <?php echo form_input('to', '', 'class="form-control" id="customer_email"');?></div>
					</div>
					<div class="form-group">
			  			<label for="subject"><?php echo $this->lang->line("subject"); ?></label>
			  			<div class="controls">
			  			<?php echo form_input('subject', '', 'class="form-control" id="subject"');?> </div>
					</div>
					<div class="form-group">
			  			<label for="message"><?php echo $this->lang->line("message"); ?></label>
			  			<div class="controls"> <?php echo form_textarea('note', $this->lang->line("find_attachment"), 'id ="message" class="form-control" placeholder="'.$this->lang->line("add_note").'" rows="3" style="margin-top: 10px; height: 100px;"');?> </div>
					</div>
		      		<input type="hidden" id="qu_id" value="" />  
			      </div>
			      	
		      	  <div class="modal-footer">
		        	<button class="btn" data-dismiss="modal" aria-hidden="true"><?php echo $this->lang->line('sale_close'); ?></button>
		        	<button class="btn btn-primary" id="email_now"><?php echo $this->lang->line('send_email'); ?></button>
		      	  </div>
			</div>
		</div>
	</div>
<?php echo $footer ?>